package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AIntellectualInfo;
import com.lxmes.pm.service.IAIntellectualInfoService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 知识产权信息Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/intellectualInfo")
public class AIntellectualInfoController extends BaseController
{
    @Autowired
    private IAIntellectualInfoService aIntellectualInfoService;

    /**
     * 查询知识产权信息列表
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(AIntellectualInfo aIntellectualInfo)
    {
        startPage();
        List<AIntellectualInfo> list = aIntellectualInfoService.selectAIntellectualInfoList(aIntellectualInfo);
        return getDataTable(list);
    }

    /**
     * 导出知识产权信息列表
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:export')")
    @Log(title = "知识产权信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AIntellectualInfo aIntellectualInfo)
    {
        List<AIntellectualInfo> list = aIntellectualInfoService.selectAIntellectualInfoList(aIntellectualInfo);
        ExcelUtil<AIntellectualInfo> util = new ExcelUtil<AIntellectualInfo>(AIntellectualInfo.class);
        util.exportExcel(response, list, "知识产权信息数据");
    }

    /**
     * 获取知识产权信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aIntellectualInfoService.selectAIntellectualInfoById(id));
    }

    /**
     * 新增知识产权信息
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:add')")
    @Log(title = "知识产权信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AIntellectualInfo aIntellectualInfo)
    {
        return toAjax(aIntellectualInfoService.insertAIntellectualInfo(aIntellectualInfo));
    }

    /**
     * 修改知识产权信息
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:edit')")
    @Log(title = "知识产权信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AIntellectualInfo aIntellectualInfo)
    {
        return toAjax(aIntellectualInfoService.updateAIntellectualInfo(aIntellectualInfo));
    }

    /**
     * 删除知识产权信息
     */
    @PreAuthorize("@ss.hasPermi('pm:intellectualInfo:remove')")
    @Log(title = "知识产权信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aIntellectualInfoService.deleteAIntellectualInfoByIds(ids));
    }
}
